/*
 * Copyright (c) 2016. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.freecsim.markdown.sql;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.freecsim.markdown.IMarkdownModel;



public class DocTable implements IMarkdownModel{

    /**
     * 表名称
     */
	private String name;

    /**
     * 表描述
     */
	private String comment;
    
	private List<DocColumn> columns;

	public String toMarkdownString() {
		StringBuilder sb = new StringBuilder();
		sb.append("#### ").append(StringUtils.defaultString(getName())).append("\n");
		sb.append(StringUtils.defaultString(getComment())).append("\n");
		sb.append("\n").append("- - -\n");
		
		sb.append("|Field Name|Data Type|NOT NULL|Default|Comment|\n");
		sb.append("|:---------|:--------|:---|:------|:------|\n");
		List<DocColumn> coList = getColumns();
		if(coList != null){
			for(DocColumn c : coList){
				sb.append(c.toMarkdownString());
			}
		}
		sb.append("\n");
		return sb.toString();
	}

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the comment
     */
    public String getComment() {
        return comment;
    }

    /**
     * @param comment the comment to set
     */
    public void setComment(String comment) {
        this.comment = comment;
    }

    /**
     * @return the columns
     */
    public List<DocColumn> getColumns() {
        return columns;
    }

    /**
     * @param columns the columns to set
     */
    public void setColumns(List<DocColumn> columns) {
        this.columns = columns;
    }
}
